import * as mobx from "mobx";

class Store {
  phone = '';
  token = "";

  constructor() {
    let phone = localStorage.getItem('phone');
    let token = localStorage.getItem('token');
    if (phone && token) {
        this.token = token;
        this.phone = phone;
    }
    mobx.makeAutoObservable(this);
  }

  // 修改电话号码
  updatePhone = (newPhone) => {
    this.phone = newPhone;
    localStorage.setItem('phone',newPhone);
  };

  // 修改token
  updateToken = (newToken) => {
    this.token = newToken;
    localStorage.setItem('token',newToken);
  };
}

export default new Store();
